<template>
	<uni-nav-bar fixed="true" statusBar="true" border="false" :left-icon="isShareEntry ? 'home' : 'left'" title="行程详情" @clickLeft="handleClickLeft"></uni-nav-bar>
	<view class="container">
		<view class="sticky" :style="{'top':showNavTop+'px'}">
			<text :class="navIndex==0?'mr100 active':'mr100'" @click="checkIndex(0)">行程详情</text><text :class="navIndex==1?'active':''" @click="checkIndex(1)">团队成员</text>
		</view>
		<view class="bottom-wrap">
			<!-- 内容切换 -->
			<view class="content" v-if="navIndex==0">
				<swiper v-if="Data.travelLinesDetailDto" class="index-swiper" :indicator-dots="true" :autoplay="true"
					:interval="5000" :duration="1000">
					<swiper-item v-for="(item,index) in Data.travelLinesDetailDto.linePicUrl" :key="index">
						<image :src="item" alt="" mode="widthFix"></image>
					</swiper-item>
				</swiper>
				<view class="uni-padding-wrap pt30 pb130" v-if="Data.travelLinesDetailDto">
					<view class="bor_d color-black p100">
						<view class="uni-flex sp_betw line-h70">
							<text class="b-font font-32">{{Data.itineraryTitle}}</text>
							<text class="b-font color-orange" v-if="Data.itinerarySta == 'ZT'">组队中</text>
							<text class="b-font uni-success" v-if="Data.itinerarySta == 'W'">待出行</text>
							<text class="b-font uni-primary" v-if="Data.itinerarySta == 'I'">出行中</text>
							<text class="b-font uni-default" v-if="Data.itinerarySta == 'O'">已完成</text>
							<text class="b-font uni-default" v-if="Data.itinerarySta == 'X'">已取消</text>
						</view>
						<view class="uni-flex sp_betw line-h70">
							<text>城市&nbsp;&nbsp;&nbsp;&nbsp;{{Data.travelLinesDetailDto.linesCityDesc}}</text>
							<text>{{Data.travelLinesDetailDto.createDate}}&nbsp;&nbsp;&nbsp;&nbsp;发布</text>
						</view>
						<view class="is-flex line-h70">
							难度&nbsp;&nbsp;&nbsp;&nbsp;<uni-rate max="5" :readonly="true" v-model="Data.travelLinesDetailDto.linesStar" />
						</view>
					</view>
					<view class="bor_d p100">
						<view class="bg-white uni-flex boxsiz ac">
							<view class="avatar mr15" @tap="navgetTo('pages/schdule/ld_schdule',Data,'')">
								<image mode="aspectFill" :src="leaderUserInfo.headerPic || 'https://green-leader.oss-cn-hangzhou.aliyuncs.com/common/%E5%8F%8B%E6%AD%A5%E9%A2%86%E9%98%9Flogo.png'"></image>
							</view>
							<view class="flex1">
								<view class="uni-flex sp_betw mb20">
									<view class="gender">
										<text class="lineBlock">{{leaderUserInfo.nickName}}&nbsp;&nbsp;<text class="gender-icon color-blue b-font" v-if="leaderUserInfo.sex === 0">♂</text><text class="gender-icon color-red b-font" v-if="leaderUserInfo.sex === 1">♀</text></text>
									</view>
									<view class="">
										<text v-if="Data.roleOnItinerary != 'MEMBER'" class="map-text sign-status uni-success" @tap="navgetTo('pages/schdule/ld_schdule',Data,'')">查看主页</text>
										<text v-if="Data.roleOnItinerary == 'MEMBER'" class="map-text sign-status uni-success" @click="playphone(leaderUserInfo.mobile)">联系领队</text>
									</view>
								</view>
								<view class="">
									<text class="mr100">带队&nbsp;&nbsp;{{leaderUserInfo.leaderCount}}次</text>
									<text>评分&nbsp;&nbsp;{{leaderUserInfo.recommendScore}}分</text>
								</view>
							</view>
						</view>
					</view>
					<view class="bor_d color-black p100 xc-info">
						<view class="xc-desc text-justify">
							<text>{{Data.travelLinesDetailDto.linesBrief}}</text>
						</view>
					</view>
					<view class="bor_d color-black p100">
						<view class="is-flex mb15">
							<uni-icons type="personadd" size="20"
								color="#37b64a"></uni-icons><text class="ml20">上限人数&nbsp;&nbsp;&nbsp;&nbsp;{{Data.userLimit}}人</text>
						</view>
						<view class="is-flex mb15">
							<uni-icons type="auth" size="20"
								color="#37b64a"></uni-icons><text class="ml20">成团人数&nbsp;&nbsp;&nbsp;&nbsp;{{Data.compositionNum}}人</text>
						</view>
						<view class="is-flex mb15">
							<uni-icons type="wallet" size="20"
								color="#37b64a"></uni-icons><text class="ml20">行程费用&nbsp;&nbsp;&nbsp;&nbsp;{{Data.itineraryFee}}元</text>
						</view>
						<view class="is-flex mb15">
							<uni-icons type="minus" size="20"
								color="#37b64a"></uni-icons><text class="ml20">报名期限&nbsp;&nbsp;&nbsp;&nbsp;{{Data.expireDate}}止</text>
						</view>
						<view class="is-flex mb15">
							<uni-icons type="minus" size="20"
								color="#37b64a"></uni-icons><text class="ml20">集合时间&nbsp;&nbsp;&nbsp;&nbsp;{{Data.collectDate}}</text>
						</view>
						<view class="uni-flex ac sp_betw mb15">
							<view class="mapStyle">
							<uni-icons type="location" size="20"
								color="#37b64a"></uni-icons><text class="ml20 mr40 mapText">集合地点&nbsp;&nbsp;&nbsp;&nbsp;{{Data.collectAddress}}</text>
							</view>
							<view class="mapIcon">
							<uni-icons type="paperplane" size="20" color="#37b64a"></uni-icons><text class="map-text font_size_22 sign-status uni-primary"
								@tap="openTencentMapNavigation">地图导航</text>
							</view>
						</view>
					</view>
					<view class="bor_d color-black p100 xc-info mb40">
						<text>
							{{Data.itineraryContent}}
						</text>
					</view>
					<view class="share-reward color-black" v-if="Data.itinerarySta == 'ZT' && Data.promotionSwitch == 'T'">
						<view class="uni-flex sp_betw">
							<view class="is-flex">
								<text class="b-font color-black">分享奖励</text>
								<uni-icons type="info" size="20" color="#888"></uni-icons>
							</view>
							<view class="">
								<button open-type="share" class="share-btn sign-status uni-success">分享</button>
							</view>
						</view>
						<view class="is-flex">
							<text class="color-gray">领队已打开分享推广奖励，用户可通过分享报名链接邀请好友报名，分享链接成交的订单将获得订单成交金额的3%服务费奖励，奖励将在行程结束后次日通过用户钱包结算，用户可在钱包内申请提现。</text>
						</view>
					</view>
					<view class="share-reward color-black" v-if="Data.promotionSwitch == 'F' && Data.roleOnItinerary == 'LEADER' && Data.itinerarySta == 'ZT'">
						<view class="uni-flex sp_betw">
							<view class="is-flex">
								<text class="b-font color-black">分享链接邀请组队</text>
								<uni-icons type="info" size="20" color="#888"></uni-icons>
							</view>
							<view class="">
								<button open-type="share" class="share-btn sign-status uni-success">分享</button>
							</view>
						</view>
						<view class="is-flex">
							<!-- <text class="color-gray">领队已打开分享推广奖励，用户可通过分享报名链接邀请好友报名，分享链接成交的订单将获得订单成交金额的3%服务费奖励，奖励将在行程结束后次日通过用户钱包结算，用户可在钱包内申请提现。</text> -->
						</view>
					</view>
				</view>
			</view>
			<!-- 内容切换 -->
			<view class="content" v-if="navIndex==1">
				<view class="vt50 tc" v-if="List.length == 0">
					<view>暂无报名成员</view>
					<button class="default-button color-blue" open-type="share">邀请成员>></button>
				</view>
				<scroll-view scroll-y="true" :style="{height:scrollH+'px'}" refresher-enabled="true" :refresher-triggered="isRefreshing" @refresherrefresh="onRefresh" @scrolltolower="onLoadMore">
				<view class="pb130" v-if="List.length>0">
					<view class="card-list is-flex p3020 b-dash" v-for="item in List">
						<image class="teamImage" :src="item.userDetailDto.headerPic" mode="aspectFill"></image>
						<view class="card-item flex1">
							<view class="uni-flex">
								<view class="uni-flex gender mb25"><text class="mr15">昵称</text>{{item.userDetailDto.nickName}}<text v-if="item.userDetailDto.sex == 0" class="gender-icon color-blue">&nbsp;&nbsp;♂</text><text v-if="item.userDetailDto.sex == 1" class="gender-icon color-red">&nbsp;&nbsp;♀</text></view>
								<view class="">
									<text class="sign-status uni-success" v-if="item.userDetailDto.sta == 'END'">已取消</text>
									<text class="sign-status uni-warning" v-if="item.userDetailDto.sta == 'PAY'">已支付</text>
									<text class="sign-status uni-default" v-if="item.userDetailDto.sta == 'CANCEL'">已取消</text>
									<text class="sign-status uni-default" v-if="item.userDetailDto.sta == 'OVER'">已评价</text>
								</view>
							</view>
							<view class="">
								<text>签名&nbsp;&nbsp;</text>{{item.userDetailDto.signature}}
							</view>
						</view>
					</view>
				<!-- 加载提示 -->
					 <view v-if="isLoading" class="tc mb100">{{loadMoreText}}</view>
				</view>
				</scroll-view>
			</view>
		</view>
		<view class="fixed-bottom-wrap" v-if="navIndex == 0 || (Data.roleOnItinerary == 'VISIT' && Data.itinerarySta == 'ZT') || (Data.roleOnItinerary == 'MEMBER' && Data.itinerarySta == 'O') || (Data.roleOnItinerary == 'LEADER' && (Data.itinerarySta == 'ZT' || Data.itinerarySta == 'W' || Data.itinerarySta == 'I'))">
			<view class="schdule-card uni-flex">
				<view class="flex-item wd100 sign bg-green" v-if="(Data.roleOnItinerary == 'VISIT' && Data.itinerarySta == 'ZT') || (isShareEntry && Data.itinerarySta != 'X')" @click="sign">
					<text>我要报名</text>
				</view>
				<view class="flex-item wd100 sign bg-green" v-if="Data.roleOnItinerary == 'MEMBER' && Data.itinerarySta == 'O' && Data.recommendFlag=='F'"
					@tap="navgetTo('pages/schdule/create_schdule_evaluate',Data,'')">
					<text>行程评价</text>
				</view>
				<view class="flex-item wd100 sign bg-green" v-if="Data.roleOnItinerary == 'MEMBER' && Data.itinerarySta == 'O' && Data.recommendFlag=='T'"
					@tap="navgetTo('pages/schdule/view_schdule_evaluate',Data,'')">
					<text>查看评价</text>
				</view>
				<view class="flex-item wd50 sign bg-graybe" v-if="Data.roleOnItinerary == 'LEADER' && (Data.itinerarySta == 'ZT' || Data.itinerarySta == 'W')"
					@click="open('cancelItinerary')">
					<text>取消行程</text>
				</view>
				<view class="flex-item wd50 sign bg-orange" v-if="Data.roleOnItinerary == 'LEADER' && Data.itinerarySta == 'ZT'" @click="open('groupItinerary')">
					<text>直接成团</text>
				</view>
				<view class="flex-item wd50 sign bg-green" v-if="Data.roleOnItinerary == 'LEADER' && Data.itinerarySta == 'W'"
					@click="open('Itinerarying');">
					<text>确认出发</text>
				</view>
				<view class="flex-item wd100 sign bg-green" v-if="Data.roleOnItinerary == 'LEADER' && Data.itinerarySta == 'I'"
					@click="open('closeItinerary')">
					<text>确认完成</text>
				</view>
				<!-- <view class="flex-item wd100 sign bg-green" v-if="Data.itinerarySta == 'O' && Data.recommendFlag=='F'"
					@tap="navgetTo('pages/schdule/create_schdule_evaluate',Data,'')">
					<text>行程评价</text>
				</view>
				<view class="flex-item wd100 sign bg-green" v-if="Data.itinerarySta == 'O' && Data.recommendFlag=='T'"
					@tap="navgetTo('pages/schdule/view_schdule_evaluate',Data,'')">
					<text>查看评价</text>
				</view> -->
			</view>
		</view>
		<!-- 取消行程弹框 -->
		<uni-popup ref="cancelItinerary" type="dialog" class="pop_dialog">
			<uni-popup-dialog :type="msgType" cancelText="暂不取消" confirmText="确认取消" title="取消确认"
				content="取消行程将同步订单并退款是否确认取消" @confirm="cancelItineraryConfirm(Data.id)"
				@close="close('cancelItinerary')">
			</uni-popup-dialog>
		</uni-popup>
		<!-- 直接成团确认弹框 -->
		<uni-popup ref="groupItinerary" type="dialog" class="pop_dialog">
			<uni-popup-dialog :type="msgType" cancelText="暂不成团" confirmText="确认成团" title="成团确认" content="未满足成团人数，是否确认成团"
				@confirm="groupItineraryConfirm(Data.id)" @close="close('groupItinerary')">
			</uni-popup-dialog>
		</uni-popup>
		<!-- 确认出发弹框 -->
		<uni-popup ref="Itinerarying" type="dialog" class="pop_dialog">
			<uni-popup-dialog :type="msgType" cancelText="暂不确认" confirmText="确认出行" title="确认出行"
				content="请盘点成员到齐后，确认开始行程" @confirm="ItineraryingConfirm(Data.id)" @close="close('Itinerarying')">
			</uni-popup-dialog>
		</uni-popup>
		<!-- 确认完成弹框 -->
		<uni-popup ref="closeItinerary" type="dialog" class="pop_dialog">
			<uni-popup-dialog :type="msgType" cancelText="暂不确认" confirmText="确认完成" title="确认完成" content="请确认行程是否已完成"
				@confirm="closeItineraryConfirm(Data.id)" @close="close('closeItinerary')">
			</uni-popup-dialog>
		</uni-popup>
	</view>
	<loginwx ref="login"></loginwx>
</template>

<script>
	import api from '@/common/api/webapi.js'; /*api*/
	import storageUtil from '@/common/util/storageUtil.js';
	import loginwx from '@/components/login-wx/loginwx.vue';
	export default {
		components: {
			loginwx
		},
		data() {
				const currentDate = this.getDate({
					format: true
				})
				return {
					msgType: 'info',
					Data: {},
					leaderUserInfo:{},
					showNavTop:88,
					mapInfo: {
						collectLng: '',
						collectLat: '',
						collectAddress: '',
					},
					InternanyId:'',
					starValue: 0,
					date: currentDate,
					scrollH:0,
					isRefreshing:false,
					isLoading:false,
					loadMoreText:"加载中...",
					navIndex:0,
					isShareEntry: false,
					orderData:{},
					List:[
					{
					  "id": 0,
					  "userId": 0,
					  "travelLinesId": 0,
					  "travelItineraryId": 0,
					  "orderNo": "",
					  "sta": "",
					  "createDate": "",
					  "userDetailDto": {
						"mobile": "",
						"nickName": "",
						"signature": "",
						"sex": 0,
						"headerPic": "",
						"age": 0,
						"memberAccount": ""
					  }
					}
				],
				param: {
					page: 1, //当前页
					limit: 10, //每页显示记录数
					PageCount: 0,
					latitude: 25.040609, //默认为昆明市经纬度坐标
					longitude: 102.712251, //默认为昆明市经纬度坐标
					cityCode:0,
					locationCityName:"",
					collectDate:"",
				},
			}
		},
		computed: {
			startDate() {
				return this.getDate('start');
			},
			endDate() {
				return this.getDate('end');
			}
		},
		watch: {

		},
		onReady() {
			// 获取可滚动区域的高度：视口高度 - tabbar切换卡高度就是剩余的内容可滚动的。
			//如果你使用取消了原生导航栏，记着把你自定义导航栏的高度也减掉哦
			uni.getSystemInfo({
				success: (res) => {
					this.scrollH = res.windowHeight - 128 - uni.upx2px(100)
				}
			})
		},
		onShow() {
			// 检查登录状态并刷新页面数据
			let userLoginFlag = storageUtil.getStorageData("isLogin");
			if (userLoginFlag) {
				// 如果已登录，刷新详情页数据
				if(this.InternanyId) {
					this.GetDetailInfo(this.InternanyId);
				}
			}
			// 重置登录组件的回调，确保登录成功后能刷新页面
			if(this.$refs.login) {
				this.$refs.login.callback = () => {
					// 登录成功后强制刷新详情页数据
					if(this.InternanyId) {
						this.GetDetailInfo(this.InternanyId);
					}
				};
			}
		},
		onLoad(option) {
				const app = getApp()
				this.navTop = app.globalData.navTop;
				this.showNavTop = this.navTop + 44;
				// 判断是否从分享进入
				this.isShareEntry = option.LeaderUserId && option.schduleId && option.memberAccount;
				if(option.LeaderUserId && option.schduleId){
					this.LeaderUserId = option.LeaderUserId;
					this.memberAccount = option.memberAccount;
					this.schduleId = option.schduleId;
					storageUtil.saveStorageData("LeaderUserId",option.LeaderUserId);
					storageUtil.saveStorageData("memberAccount",option.memberAccount);
					storageUtil.saveStorageData("schduleId",option.schduleId);
					this.InternanyId = option.schduleId;
				}else{
					if (option.param) {
						let params = JSON.parse(decodeURIComponent(option.param));
						this.InternanyId = params.data;
					}
				}
				this.checkIndex(0);
			},
		onShareAppMessage(options) {
			const memberAccount = storageUtil.getUserData('memberAccount');
			console.log("memberAccount",memberAccount);
			let params = {id: this.Data.id, leaderUserId: this.Data.userId};
			console.log(params);
			let path = `/pages/schdule/schdule_detail?share=true&schduleId=${params.id}&LeaderUserId=${params.leaderUserId}&memberAccount=${memberAccount}`;
			console.log("path",path);
			return {
				title: this.Data.itineraryTitle || '行程分享', // 分享标题
				path: path, // 分享的路径，可以是当前页面的路径，也可以是其他页面的路径
				imageUrl: this.Data.travelLinesDetailDto?.coverUrl || 'https://green-leader.oss-cn-hangzhou.aliyuncs.com/common/%E5%8F%8B%E6%AD%A5%E9%A2%86%E9%98%9Flogo.png?Expires=1756883866&OSSAccessKeyId=TMP.3KpSD3VRfU9KihXPDkydNDQFJg3KKHzZSyEBFUWF3pGAnyAiWYGgpjwt9uBjqRXsED9YmkZvTwXEzR2U9GiNpzPcSehURJ&Signature=VDiG2wlWjKtqodT48NqaykugSEM%3D' // 分享的图片链接
			};
			
		},
		onShareTimeline(options) {
			const memberAccount = storageUtil.getUserData('memberAccount');
			console.log("memberAccount",memberAccount);
			let params = {id: this.Data.id, leaderUserId: this.Data.userId};
			console.log(params);
			let path = `/pages/schdule/schdule_detail?share=true&schduleId=${params.id}&LeaderUserId=${params.leaderUserId}&memberAccount=${memberAccount}`;
			console.log("path",path);
			return {
				title: this.Data.itineraryTitle || '行程分享', // 分享标题
				path: path, // 分享的路径，可以是当前页面的路径，也可以是其他页面的路径
				imageUrl: this.Data.travelLinesDetailDto?.coverUrl || 'https://green-leader.oss-cn-hangzhou.aliyuncs.com/common/%E5%8F%8B%E6%AD%A5%E9%A2%86%E9%98%9Flogo.png?Expires=1756883866&OSSAccessKeyId=TMP.3KpSD3VRfU9KihXPDkydNDQFJg3KKHzZSyEBFUWF3pGAnyAiWYGgpjwt9uBjqRXsED9YmkZvTwXEzR2U9GiNpzPcSehURJ&Signature=VDiG2wlWjKtqodT48NqaykugSEM%3D' // 分享的图片链接
			};
		},
		methods: {
				back(){
					uni.navigateBack();
				},
				// 跳转到首页
				goHome(){
					uni.switchTab({
						url: '/pages/index/index'
					});
				},
				// 根据是否为分享进入处理左侧点击事件
				handleClickLeft(){
					if(this.isShareEntry){
						this.goHome();
					}else{
						this.back();
					}
				},
			getDate(type) {
				const date = new Date();
				let year = date.getFullYear();
				let month = date.getMonth() + 1;
				let day = date.getDate();
				if (type === 'start') {
					year = year;
				} else if (type === 'end') {
					if (month > 6) {
						year = year + 1;
					}
					year = year;
				}
				month = month > 9 ? month : '0' + month;
				day = day > 9 ? day : '0' + day;
				return `${year}-${month}-${day}`;
			},
			checkIndex(index) {
				this.navIndex = index;
				if(this.navIndex == 0){
					this.GetDetailInfo(this.InternanyId);
				}else if(this.navIndex == 1){
					this.getPageList('onPullDownRefresh');
				}
			},
			GetDetailInfo(ID) {
				let _this = this;
				api.getItineraryInfo({
					params: {
						itineraryId: ID,
					}
				}).then(res => {
					if (res.code === 0) {
						_this.Data = res.data;
						_this.GetleaderInfo(res.data.userId);
						_this.mapInfo.collectAddress = res.data.collectAddress;
						_this.mapInfo.collectLng = res.data.collectLng;
						_this.mapInfo.collectLat = res.data.collectLat;
					} else {}
				}).catch()
			},
			GetleaderInfo(userId) {
				let _this = this;
				api.leaderInfo({
					params: {
						leaderUserId : userId,
					}
				}).then(res => {
					if (res.code === 0) {
						_this.leaderUserInfo = res.data;
					} else {}
				}).catch()
			},
			// 城市选择器
			bindRegionChange: function(e) {
				this.region = e.detail.value;
			},
			// 电话领队
			playphone(mobilePhone) {
				uni.makePhoneCall({
					// 手机号 这里可以直接写号码如 12345 也可以写获取号码的字段如this.mobile
					phoneNumber: mobilePhone,
					// 成功回调
					success: (res) => {
						// console.log('调用成功!')
					},
					// 失败回调
					fail: (res) => {
						// console.log('调用失败!')
					}
				});
			},
			// 页面跳转
			navgetTo(page, param, type) {
				// let userLoginFlag = storageUtil.getStorageData("isLogin");

				// if (!userLoginFlag || userLoginFlag == '') {
				// 	this.popShowHandle();
				// 	return;
				// }
				if (param != undefined) {
					type = type || '';
					let data = {
						data: param,
						page: type
					}
					uni.navigateTo({
						url: "/" + page + "?param=" + encodeURI(JSON.stringify(data))
					});
				} else {
					uni.navigateTo({
						url: "/" + page
					});
				}
			},
			sign(){
				let userLoginFlag = storageUtil.getStorageData("isLogin");
				if (userLoginFlag) {
					let phone = storageUtil.getUserData('mobile');
					let curNickName = storageUtil.getUserData('nickName');
					this.orderData.travelItineraryId = this.Data.id;
					this.orderData.travelLinesId = this.Data.travelLinesDetailDto.id;
					this.orderData.signUser = curNickName;
					this.orderData.signMobile = phone;
					this.orderData.itineraryFee = this.Data.itineraryFee;
					if(this.orderData.signUser == this.Data.userName){
						uni.showToast({
							icon: 'none',
							title: '领队不能报名自己的行程哦！'
						});
						return;
					}
					if(this.Data.roleOnItinerary == 'MEMBER'){
						uni.showToast({
							icon: 'none',
							title: '已经报名了，不能重复报名哦！'
						});
						return;
					}
					console.log("Data",this.Data);
					uni.navigateTo({
						url:'/pages/agreement/group_privacy_sign?param='+encodeURI(JSON.stringify(this.orderData))
					})
				}else{
					this.popShowHandle();
				}
			},
			popShowHandle() {
				setTimeout(() => {
					let _this = this;
					// 设置登录成功回调
					this.$refs.login.callback = () => {
						// 登录成功后强制刷新详情页数据
						if(_this.InternanyId) {
							_this.GetDetailInfo(_this.InternanyId);
						}
					};
					_this.$refs.login.open();
				}, 50);
			},
			// 打开地图导航（微信小程序专用）
			openTencentMapNavigation() {
				const { collectLat, collectLng, collectAddress } = this.mapInfo;
				if (!collectLat || !collectLng) {
					uni.showToast({
						title: '暂无导航信息',
						icon: 'none'
					});
					return;
				}

				try {
					// 在微信小程序中直接使用微信地图API
					uni.openLocation({
						latitude: Number(collectLat),
						longitude: Number(collectLng),
						address: collectAddress || '集合地点',
						name: collectAddress || '集合地点',
						success() {
							console.log('打开地图成功');
						},
						fail(err) {
							console.error('打开地图失败', err);
							uni.showToast({
								title: '打开地图失败，请检查是否开启位置权限',
								icon: 'none'
							});
						}
					});
				} catch (error) {
					console.error('地图导航出错:', error);
					uni.showToast({
						title: '地图导航异常，请重试',
						icon: 'none'
					});
				}
			},
			// 微信分享
			handleshare() {
				uni.showShareMenu({
					withShareTicket: true,
					menus: ['shareAppMessage', 'shareTimeline'],
				})
			},
			// 取消行程确认
			cancelItineraryConfirm(ID) {
				api.itineraryCancel({
					params: {
						travelItineraryId: ID,
					}
				}).then(res => {
					if (res.code === 0) {
						this.$refs.cancelItinerary.close();
						uni.switchTab({
							url: '/pages/schdule/schdule',
							success() {
								var page = getCurrentPages().pop();
								if (page == undefined || page == null) return;
								page.onLoad();
							}
						});
					} else {}
				}).catch()
			},
			// 直接成团确认
			groupItineraryConfirm(ID) {
				api.itineraryct({
					params: {
						travelItineraryId: ID,
					}
				}).then(res => {
					if (res.code === 0) {
						this.$refs.groupItinerary.close();
						uni.switchTab({
							url: '/pages/schdule/schdule',
							success() {
								var page = getCurrentPages().pop();
								if (page == undefined || page == null) return;
								page.onLoad();
							}
						});
					} else {}
				}).catch()
			},
			//确认出发确认
			ItineraryingConfirm(ID) {
				api.itinerarystart({
					params: {
						travelItineraryId: ID,
					}
				}).then(res => {
					if (res.code === 0) {
						this.$refs.Itinerarying.close();
						uni.switchTab({
							url: '/pages/schdule/schdule',
							success() {
								var page = getCurrentPages().pop();
								if (page == undefined || page == null) return;
								page.onLoad();
							}
						});
					} else {}
				}).catch()
			},
			// 确认完成确认
			closeItineraryConfirm(ID) {
				api.itineraryfinish({
					params: {
						travelItineraryId: ID,
					}
				}).then(res => {
					if (res.code === 0) {
						this.$refs.closeItinerary.close();
						uni.switchTab({
							url: '/pages/schdule/schdule',
							success() {
								var page = getCurrentPages().pop();
								if (page == undefined || page == null) return;
								page.onLoad();
							}
						});
					} else {}
				}).catch()
			},
			open(ele) {
				if (ele == "cancelItinerary") {
					this.$refs.cancelItinerary.open("center");
				} else if (ele == "groupItinerary") {
					this.$refs.groupItinerary.open("center");
				} else if (ele == "Itinerarying") {
					this.$refs.Itinerarying.open("center");
				} else if (ele == "closeItinerary") {
					this.$refs.closeItinerary.open("center");
				}
			},
			close(ele) {
				if (ele == "cancelItinerary") {
					this.$refs.cancelItinerary.close();
				} else if (ele == "groupItinerary") {
					this.$refs.groupItinerary.close();
				} else if (ele == "Itinerarying") {
					this.$refs.Itinerarying.close();
				} else if (ele == "closeItinerary") {
					this.$refs.closeItinerary.close();
				}
			},
			onRefresh() {  // 下拉刷新
				this.isRefreshing = true;
				this.param.page = 1;
				this.getPageList('onPullDownRefresh');
			},
			onLoadMore() {  // 上拉加载
				if (this.isLoading) return;
				this.isLoading = true;
				this.param.page = (this.param.page + 1);
				if (this.param.page > this.param.PageCount) {
					this.isLoading = true;
					this.loadMoreText = "到底了!"
					return;
				}
				this.getPageList('onReachBottom');
			},
			// 获取分页列表
			getPageList(type) {
				let _this = this;
				let requestData = {
					params: {
						page: _this.param.page, //当前页
						size: _this.param.limit, //每页显示记录数
						travelItineraryId:_this.Data.id,
					}
				}
				api.leaderItineraryMemberList(requestData).then(res => {
					if (res.code === 0) {
						if (res.data.length > 0) {
							let pagelist = res.data;
							if (type == "onReachBottom") {
								_this.List = _this.List.concat(pagelist)
							} else {
								_this.List = pagelist;
							}
						}else{
							if(type == "onPullDownRefresh"){
								_this.List = [];
							}else if(type == "onReachBottom"){
								this.loadMoreText = "--到底啦--"
							}
						}
					} else {}
				_this.isRefreshing = false;
				_this.loadMoreText = "";
				}).catch(function(){
					_this.isRefreshing = false;
					_this.loadMoreText = "";
				})
			
			},
		}
	}
</script>

<style lang="scss" scoped>
	.container {
		font-size: 14px;
		line-height: 24px;
	}

	.index-swiper {
		width: 100%;
		height: 998rpx;
		position: relative;
	}

	.index-swiper image {
		width: 100%;
		height: 100%;
		object-fit: contain;
	}

	.bottom-wrap {
		position: relative;
		padding-top: 74rpx;
	}

	.is-flex {
		display: flex;
		align-items: center;
	}

	.xf-wrap {
		position: relative;
		top: -60rpx;
		overflow: hidden;
	}

	.box-shadow {
		box-shadow: 2rpx 2px 2rpx $uni-text-color-grey8;
		background-color: #ffffff;
		border-radius: 20rpx;
	}

	.xf-wrap input {
		font-weight: bold;
	}

	.uni-flex {
		display: flex;
		align-items: flex-start;
	}
	
	.share-btn{
		width: 120rpx;
		height: 50rpx;
		line-height: 50rpx;
		background-color: #fff;
	}

	.uni-row {
		flex-direction: row;
	}

	.flex-item {
		text-align: center;
	}
	
	.flex-item.wd50 {
		width: 50%;
	}

	.flex-item.wd100 {
		width: 100%;
	}

	.current-trip {
		color: $uni-text-color-light-blue;
		font-size: 28rpx;
		font-weight: bold;
		padding: 10rpx 20rpx;
	}

	.active {
		color: $uni-text-color-blue;
		border-bottom: 2px solid $uni-text-color-blue;
	}
	
	.gender{
		position: relative;
	}

	.gender-icon {
		position: absolute;
		right: -30rpx;
		top: -12rpx;
	}

	.search_btn {
		background-color: $uni-text-color-green;
		font-size: 14px;
		border: none;
		color: #fff;

	}

	.sticky {
		height: 74rpx;
		line-height: 85rpx;
		background-color: #ffffff;
		width: 100%;
		color: #888;
		position: fixed;
		top: -1rpx;
		left: 0;
		right: 0;
		z-index: 999;
		padding: 0 15px;
		text-align: center;
	}

	.sticky text {
		color: $uni-text-color-light-blue;
		font-weight: bold;
		padding: 10rpx 15rpx;
	}

	.sticky text.active {
		color: $uni-text-color-blue;
		border-bottom: 2px solid $uni-text-color-blue;
	}

	.xc-desc {
		text {
			margin-bottom: 30rpx;
			display: block;
		}
	}

	.xc-info {

		.map-text {
			color: $uni-text-color-blue;
			font-size: 16rpx;
			padding: 5rpx 10rpx;
			border: 1px solid $uni-text-color-blue;
			border-radius: 10rpx;
		}
	}
	
	/* 用户信息区域 */
	.avatar {
		width: 120rpx;
		height: 120rpx;
		text-align: right;
		image {
			width: 120rpx;
			height: 120rpx;
			object-fit: cover;
			border-radius: 50%;
		}
	}
	
	.share-btn{
		width: 120rpx;
		height: 50rpx;
		line-height: 50rpx;
		background-color: #fff;
	}
	

	.pb130 {
		padding-bottom: calc(130rpx + max(env(safe-area-inset-bottom),20px));
	}
	
	.teamImage{
		width: 160rpx;
		height: 160rpx;
		object-fit: cover;
		border-radius: 50%;
		
	}

	.share-reward {
		.color-black {
			display: block;
			margin-bottom: 20rpx;
		}

		.is-flex {
			align-items: flex-start;
		}

		.color-gray {
			line-height: 1.8;
			text-align: justify;
			margin-left: 20rpx;
		}
	}
	.sign-status{
		// color: #888;
		border: 1px solid #888;
		border-radius: 10rpx;
		padding: 0 15rpx;
	}
	.sign-status.uni-warning{
		color: $uni-text-color-orange;
		border: 1px solid $uni-text-color-orange;
	}
	.sign-status.uni-success{
		color: $uni-text-color-green;
		border: 1px solid $uni-text-color-green;
		font-size: 24rpx;
		display: inline-block;
		height: 50rpx;
		line-height: 50rpx;
	}
	.sign-status.uni-primary{
		color: $uni-text-color-blue;
		border: 1px solid $uni-text-color-blue;
		display: inline-block;
		height: 50rpx;
		line-height: 50rpx;
	}
	.sign-status.uni-default{
		color: #000;
		border: 1px solid #888;
	}

	.fixed-bottom-wrap {
		position: fixed;
		z-index: 111;
		bottom: 0;
		left: 0;
		right: 0;
		background-color: #fff;
		width: 100%;
		height: calc(60rpx + max(env(safe-area-inset-bottom),20px));
		line-height: calc(60rpx + max(env(safe-area-inset-bottom),20px));
	}
	.default-button{
		background-color: transparent;
		border: none;
		border-radius: 0;
		font-size: 28rpx;
	}
	::v-deep wx-button:after{
		border: none;
	}

	.schdule-card {
		height: calc(60rpx + max(env(safe-area-inset-bottom),20px));
		line-height: 60rpx;
		border-top: 1px solid #f8f8f8;
		padding-bottom: max(env(safe-area-inset-bottom),20px);

		.flex-item {
			text-align: center;
		}

		text {
			display: block;
		}

		.sign {
			height: 100%;
			color: $uni-text-color-white;
			font-size: 32rpx;
			line-height: 100%;
			border-radius: 0;
			text {
				line-height: 100rpx;
			}
		}
	}
	
	.mapStyle{
		display: inline-flex;
		width: calc( 100% - 160rpx );
		align-items: center;
	}
	.mapText{
		display: inline-block;
		width: 86%;
		white-space: nowrap;
		overflow: hidden;
		text-overflow: ellipsis;
	}
	.mapIcon{
		width: 160rpx;
	}

	// 弹出框样式
	::v-deep .uni-dialog-title-text {
		font-size: $uni-font-size-36;
		font-weight: 500;
		color: $uni-text-color-normal;
		line-height: 45rpx;
	}

	::v-deep .uni-dialog-content-text {
		font-size: $uni-font-size-26;
		color: $uni-text-color-grey6;
		line-height: 52rpx;
	}

	::v-deep .uni-dialog-button {
		margin: 30rpx 0;
	}

	::v-deep .pop_dialog .uni-button-color {
		color: $uni-text-color-green;
	}

	::v-deep .uni-border-left {
		border-left: none;
	}
</style>